﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;


namespace DeviceMonitor
{
    public class BoolToVisibilityConverter : IValueConverter
    {
        // 将 bool 值转换为 Visibility 枚举（Visible 或 Collapsed）
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool)
            {
                bool boolValue = (bool)value;
                return boolValue ? Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        // 反向转换：在此情况下，不需要反向转换，因此返回原值
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;  // 你可以选择抛出异常或返回其他值
        }
    }
}
